﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using ClientWorkflowLibrary.DTRender;

namespace ClientWorkflowLibrary
{
	public partial class UpdateConferenceData: Activity
	{
		public UpdateConferenceData()
		{
			InitializeComponent();
		}

        /// <summary>
        /// The ID of the talk in the database
        /// </summary>
        public int TalkID
        {
            get { return (int)GetValue(TalkIDProperty); }
            set { SetValue(TalkIDProperty, value); }
        }

        // Using a DependencyProperty as the backing store for TalkID.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TalkIDProperty =
            DependencyProperty.Register("TalkID", typeof(int), typeof(UpdateConferenceData), new PropertyMetadata(0));

        /// <summary>
        /// The new title
        /// </summary>
        public string ConferenceTitle
        {
            get { return (string)GetValue(ConferenceTitleProperty); }
            set { SetValue(ConferenceTitleProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ConferenceTitle.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ConferenceTitleProperty =
            DependencyProperty.Register("ConferenceTitle", typeof(string), typeof(UpdateConferenceData), new PropertyMetadata(""));

        /// <summary>
        /// The end time for this conference.
        /// </summary>
        public DateTime ConferenceEndTime
        {
            get { return (DateTime)GetValue(ConferenceEndTimeProperty); }
            set { SetValue(ConferenceEndTimeProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ConferenceEndTime.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ConferenceEndTimeProperty =
            DependencyProperty.Register("ConferenceEndTime", typeof(DateTime), typeof(UpdateConferenceData), new PropertyMetadata(0));

        /// <summary>
        /// The time the conference starts
        /// </summary>
        public DateTime ConferenceStartTime
        {
            get { return (DateTime)GetValue(ConferenceStartTimeProperty); }
            set { SetValue(ConferenceStartTimeProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ConferenceStartTime.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ConferenceStartTimeProperty =
            DependencyProperty.Register("ConferenceStartTime", typeof(DateTime), typeof(UpdateConferenceData), new PropertyMetadata(DateTime.Now));

        /// <summary>
        /// The render client that we can use to access callbacks on!
        /// </summary>
        public DTRenderClient Render
        {
            get { return (DTRenderClient)GetValue(RenderProperty); }
            set { SetValue(RenderProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Render.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty RenderProperty =
            DependencyProperty.Register("Render", typeof(DTRenderClient), typeof(UpdateConferenceData), new PropertyMetadata(null));


        /// <summary>
        /// Update the DB with the info we know about now
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            Render.UpdateConferenceData(TalkID, ConferenceTitle, ConferenceStartTime, ConferenceEndTime);
            return ActivityExecutionStatus.Closed;
        }
	}
}
